package ualrcdg.shared.dto;

import java.util.Arrays;

/**
 * Simple implementation of the "ruleSet" object. See CDG XML Specifications: Game Descriptor Files.
 */
public class RuleSet implements AbstractRule
{
	//LATER add expression validator - private static final expressionTester...
	
	final private String id;
	final private String name;
	final private String[] ruleIds;
	final private String expression;
	
	/**
	 * Primary constructor
	 *
	 * @param id the id of the RuleSet object to be created
	 * @param name the name of the RuleSet object to be created
	 * @param ruleIds the ruleIds of the RuleSet object to be created
	 * @param expression the expression of the RuleSet object to be created
	 */
	public RuleSet( String id, String name, String[] ruleIds, String expression )
	{
		this.id = id;
		this.name = name;
		//LATER test expression, throw if bad
		this.ruleIds = Arrays.copyOf( ruleIds, ruleIds.length );
		this.expression = expression;
		
		System.out.println( "Parsed: " + this.toString( ) );
	}

	/*
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString( )
	{
		return "RuleSet [id=" + id + ", name=" + name + ", ruleIds=" + Arrays.toString( ruleIds ) + ", expression=" + expression + "]";
	}

	/**
	 * @return the name of this RuleSet instance
	 */
	public String getName( )
	{
		return name;
	}

	/**
	 * @return the ruleIds of this RuleSet instance
	 */
	public String getRuleIds( int index )
	{
		return ruleIds[index];
	}

	/**
	 * @return the expression of this RuleSet instance
	 */
	public String getExpression( )
	{
		return expression;
	}

	/*
	 * @see ualrcdg.shared.dto.AbstractRule#getId()
	 */
	@Override
	public String getId( )
	{
		return id;
	}
}
